/**
 * 播放器方法
 * @param playerId:顶层容器ID
 * @param vid:vid
 * @param stopTime：停止的时间
 * @param stopFn：停止执行的方法
 */
var txPlayerV2 = function(playerId, vid, stopTime, stopFn) {
    var video = new tvp.VideoInfo();
    video.setVid(vid);
    var player = new tvp.Player("100%", 200);
    player.setCurVideo(video);
    var elId = 'qzlechuang_tx_player';
    var _setVideo = function(autoPlay) {
        //初始化播放器
        if(autoPlay){
            player.addParam("autoplay", true);//设置透明度
        }
        player.addParam("wmode", "transparent");//设置透明度
        player.addParam("pic", tvp.common.getVideoSnapMobile(vid)); //设置封面
        player.write(elId);
    };
    //监听播放进度
    var _monitorPlayer = function() {
        if(typeof (stopFn) !== 'function') {
            stopFn = function() {
            };
        }
        var playTime = setInterval(function() {
            var nowTime = player.getCurTime();

            if(nowTime >= stopTime) {
                //暂停
                player.callCBEvent('pause');
                //移除定时器
                clearInterval(playTime);
                stopFn();

            }
        }, 1000);
    };
    var _startPlay = function(autoPlay) {
        //创建播放器容器
        $("#" + playerId).html('<div id="' + elId + '" class="player_skin" style="padding-top:6px;"></div>');
        //播放
        _setVideo(autoPlay);
        //开始监听播放
        if(!autoPlay){
            _monitorPlayer();
        }
    };
    this.initPlay=function(){
        _startPlay(false);
    };
    this.autoPlay=function(){
        //创建播放器容器
        player.play(vid);
    };
};